<?php include $this->admin_tpl('meta', 'admin');?>
<title>选择用户 - YzmCMS内容管理系统</title>
</head>
<body>
<div class="page-container">
	<div> 
    <form action="<?php echo U(ROUTE_A);?>" method="get" id="search">
	 用户搜索：
    <span class="select-box inline">
		<select name="groupid" class="select">
			<option value="99">微信分组</option>
			<?php 
				foreach($wechat_group as $val){
					$str = $val['id']==$groupid ? 'selected' : '';
					echo '<option value="'.$val['id'].'" '.$str.'>'.$val['name'].'</option>';
				}
			?>
		</select>
	</span>
    <span class="select-box inline">
		<select name="scan" class="select">
			<option value="">来源场景</option>
			<?php 
				foreach($scan_arr as $val){
					$str = $val['scan']==$scan ? 'selected' : '';
					echo '<option value="'.$val['scan'].'" '.$str.'>'.$val['scan'].'</option>';
				}
			?>
		</select>
	</span>	
    <span class="select-box inline">
		<select name="type" class="select">
		<option <?php if(isset($_GET['type']) && $_GET['type']=='1'){?> selected <?php }?> value="1">用户备注</option>
		<option <?php if(isset($_GET['type']) && $_GET['type']=='2'){?> selected <?php }?> value="2">OpenID</option>	
		<option <?php if(isset($_GET['type']) && $_GET['type']=='3'){?> selected <?php }?> value="3">微信昵称</option>	
		</select>
	</span>
     <input type="text" name="searinfo" class="input-text" style="width:170px" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
	 </form>
	</div>
  <form method="post" action="" id="myform" class="mt-10">
  <table class="table table-border table-bg table-hover">
    <thead>
      <tr class="text-c">
        <th width="25"><input type="checkbox"></th>
		<th>微信昵称</th>
		<th>用户备注</th>
		<th>分组名称</th>
		<th>性别</th>
		<th>地区</th>
		<th width="125">关注时间</th>		
		<th width="60">来源场景</th>	
      </tr>
    </thead>
    <tbody>
		<?php 
		foreach($data as $val){
		?>
		  <tr class="text-c">
			<td><input type="checkbox" class="checkbox" value="<?php echo $val['openid']?>" name="ids[]"></td>
			<?php if($val['nickname']){ ?>
			<td class="text-l">
				<img src="<?php echo $val['headimgurl'];?>" height="25" class="radius"> <?php echo $val['nickname'];?>
			</td>
			<?php }else{ ?>
			<td>/</td>
			<?php } ?>
			<td><?php echo $val['remark'] ? $val['remark'] : '/';?></td>
			<td><?php echo $this->get_groupname($wechat_group, $val['groupid']);?></td>
			<td><?php echo $val['sex']==2 ? '女' : ($val['sex'] ? '男' : '未知');?></td>
			<td><?php echo $val['province'];?>-<?php echo $val['city'];?></td>
			<td><?php echo date("Y-m-d H:i:s",$val['subscribe_time'])?></td>
			<td><?php echo $val['scan'] ? $val['scan'] : '无';?></td>
		  </tr>		
		<?php 
		}
		?>
    </tbody>
  </table>
  <?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
  <input class="dosubmit w_100 btn-primary radius mt-10" name="dosubmit" type="button" onclick="dosub()" value="确定">
  </form>
  <div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>
<?php include $this->admin_tpl('footer', 'admin');?>

<script type="text/javascript">

	function dosub(){
		var ids = $("input[name='ids[]']:checked");
		if (ids.length<1){
		   layer.alert('请选择用户！');
		   return false;
		}	
		
		var str = '';
		$.each(ids,function(){
			if(this.checked){
				str += $(this).val() + ',';
			}
         });
		str = str.substr(0,str.length-1);
		
		var index = parent.layer.getFrameIndex(window.name);
		parent.$("#openid").val(str);
		parent.layer.close(index);
	}
</script> 

</body>
</html>